/**
 * 
 */
package com.google.code.onlineshopping4j.dto;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.google.code.onlineshopping4j.model.Currency;
import com.google.code.onlineshopping4j.model.Product;
import com.google.code.onlineshopping4j.model.ProductImage;

/**
 * @author TelmilaJ
 *
 */
public class ProductInfo {
	private Long id;
	
	private String name;

	private Double price;
	
	private Currency currency;
	
	private List<String> productImagesUrl = new ArrayList<String>();
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Currency getCurrency() {
		return currency;
	}

	public void setCurrency(Currency currency) {
		this.currency = currency;
	}
	
	public static ProductInfo getAsProduct(Product product) {
		ProductInfo productInfo = new ProductInfo();
		BeanUtils.copyProperties(product, productInfo);
		for (ProductImage productImage: product.getProductImages()) {
			productInfo.getProductImagesUrl().add(productImage.getUrl());
		}
		return productInfo;
	}

	public List<String> getProductImagesUrl() {
		return productImagesUrl;
	}

	public void setProductImagesUrl(List<String> productImagesUrl) {
		this.productImagesUrl = productImagesUrl;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

}
